#define _CRT_SECURE_NO_WARNINGS 1
//#include<iostream>
//#include<stdio.h>
//#include<stdlib.h>
//int cmp(int* a, int* b)
//{
//    return *a - *b;
//}
//
//int* findErrorNums(int* nums, int numsSize, int* returnSize)
//{
//    int i = 0;
//    *returnSize = 2;
//    int* Return = (int*)malloc(sizeof(int) * 2);
//    qsort(nums, numsSize, sizeof(int), cmp);
//    int prev = 0;
//    for (i = 0; i < numsSize; i++)
//    {
//        int curr = nums[i];
//        if (curr == prev)
//            Return[0] = prev;
//        else if (curr - prev > 1)
//            Return[1] = prev + 1;
//        prev = curr;
//    }
//    if (nums[numsSize - 1] != numsSize)
//        Return[1] = numsSize;
//    return Return;
//}
#include <stdio.h>
#include<string.h>

int is_legal(char str[], int len)
{
    int i = 0, count1 = 0, count2 = 0, count3 = 0;

    if (len < 8)
        return 0;

    if (str[0] >= '0' && str[0] <= '9')
        return 0;

    for (i = 0; i < len; i++)
    {
        if (str[i] < '0' || (str[i] > '9' && str[i] < 'A') || str[i]>'z')
            return 0;

        if (str[i] >= '0' && str[i] <= '9')
            count1++;
        if (str[i] >= 'A' && str[i] <= 'Z')
            count2++;
        if (str[i] >= 'a' && str[i] <= 'z')
            count3++;
    }
    if ((count1 > 0) + (count2 > 0) + (count3 > 0) < 2)
        return 0;
    return 1;
}

int main()
{
    int n = 0, len = 0, ret = 0;
    char str[101] = { 0 };
    scanf("%d", &n);
    while (n--)
    {
        scanf("%s", str);
        len = strlen(str);
        ret = is_legal(str, len);
        if (ret == 0)
            printf("NO\n");
        else
            printf("YES\n");
        getchar();
    }
    return 0;
}